package clientresponse;

import android.util.Log;
import clientcore.AndroidMain;
import clientcore.Question;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class ResponseQuestionLog extends ResponseFromServer {
	private static final String TAG = ResponseQuestionLog.class.getSimpleName();

    public static List<Question> questionLog;

    @Override
    public short process() {
 	   
    	questionLog = new ArrayList<Question>();
    	Question question;
    	String options;
    	
        /*Protocol:
         * (int) numResults, [(short) id, (short) type, (String) topic, (String) text,
         * (String) preparedOptions, (boolean) status, (short) choice, (short) answer]*
         */
    	int numResults = super.readInt(inFromServer);
	    for(int i=0; i<numResults; i++) {
	        question = new Question(super.readShort(inFromServer));
	        question.setType(super.readShort(inFromServer));
	        question.setTopic(super.readString(inFromServer));
	        question.setText(super.readString(inFromServer));
	        options = super.readString(inFromServer);
	        question.setStatus(super.readBoolean(inFromServer));
	        question.setChoice(super.readShort(inFromServer));
	        question.setAnswer(super.readShort(inFromServer));
	        
	        question.mySetOptions(Question.parseOptions(options));
	     	questionLog.add(question);
	    }
	        return -2;
    }
}
